moved tool enum to a Tool class
Code cleanup and improvement.
This commit is contained in:
@@ -51,21 +51,21 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
|
||||
views_.append(new TimelineAndTrackView(kTrackTypeAudio, Qt::AlignTop));
|
||||
|
||||
// Create tools
|
||||
tools_.resize(olive::tool::kCount);
|
||||
tools_.resize(::Tool::kCount);
|
||||
tools_.fill(nullptr);
|
||||
|
||||
tools_.replace(olive::tool::kPointer, std::make_shared<PointerTool>(this));
|
||||
// tools_.replace(olive::tool::kEdit, new PointerTool(this)); FIXME: Implement
|
||||
tools_.replace(olive::tool::kRipple, std::make_shared<RippleTool>(this));
|
||||
tools_.replace(olive::tool::kRolling, std::make_shared<RollingTool>(this));
|
||||
tools_.replace(olive::tool::kRazor, std::make_shared<RazorTool>(this));
|
||||
tools_.replace(olive::tool::kSlip, std::make_shared<SlipTool>(this));
|
||||
tools_.replace(olive::tool::kSlide, std::make_shared<SlideTool>(this));
|
||||
tools_.replace(olive::tool::kHand, std::make_shared<HandTool>(this));
|
||||
tools_.replace(olive::tool::kZoom, std::make_shared<ZoomTool>(this));
|
||||
tools_.replace(olive::tool::kTransition, std::make_shared<TransitionTool>(this));
|
||||
//tools_.replace(olive::tool::kRecord, new PointerTool(this)); FIXME: Implement
|
||||
tools_.replace(olive::tool::kAdd, std::make_shared<AddTool>(this));
|
||||
tools_.replace(::Tool::kPointer, std::make_shared<PointerTool>(this));
|
||||
// tools_.replace(::Tool::kEdit, new PointerTool(this)); FIXME: Implement
|
||||
tools_.replace(::Tool::kRipple, std::make_shared<RippleTool>(this));
|
||||
tools_.replace(::Tool::kRolling, std::make_shared<RollingTool>(this));
|
||||
tools_.replace(::Tool::kRazor, std::make_shared<RazorTool>(this));
|
||||
tools_.replace(::Tool::kSlip, std::make_shared<SlipTool>(this));
|
||||
tools_.replace(::Tool::kSlide, std::make_shared<SlideTool>(this));
|
||||
tools_.replace(::Tool::kHand, std::make_shared<HandTool>(this));
|
||||
tools_.replace(::Tool::kZoom, std::make_shared<ZoomTool>(this));
|
||||
tools_.replace(::Tool::kTransition, std::make_shared<TransitionTool>(this));
|
||||
//tools_.replace(::Tool::kRecord, new PointerTool(this)); FIXME: Implement
|
||||
tools_.replace(::Tool::kAdd, std::make_shared<AddTool>(this));
|
||||
|
||||
import_tool_ = std::make_shared<ImportTool>(this);
|
||||
|
||||
|
||||
@@ -34,18 +34,18 @@ Toolbar::Toolbar(QWidget *parent) :
|
||||
layout_->setMargin(0);
|
||||
|
||||
// Create standard tool buttons
|
||||
btn_pointer_tool_ = CreateToolButton(olive::tool::kPointer);
|
||||
btn_edit_tool_ = CreateToolButton(olive::tool::kEdit);
|
||||
btn_ripple_tool_ = CreateToolButton(olive::tool::kRipple);
|
||||
btn_rolling_tool_ = CreateToolButton(olive::tool::kRolling);
|
||||
btn_razor_tool_ = CreateToolButton(olive::tool::kRazor);
|
||||
btn_slip_tool_ = CreateToolButton(olive::tool::kSlip);
|
||||
btn_slide_tool_ = CreateToolButton(olive::tool::kSlide);
|
||||
btn_hand_tool_ = CreateToolButton(olive::tool::kHand);
|
||||
btn_zoom_tool_ = CreateToolButton(olive::tool::kZoom);
|
||||
btn_record_ = CreateToolButton(olive::tool::kRecord);
|
||||
btn_transition_tool_ = CreateToolButton(olive::tool::kTransition);
|
||||
btn_add_ = CreateToolButton(olive::tool::kAdd);
|
||||
btn_pointer_tool_ = CreateToolButton(Tool::kPointer);
|
||||
btn_edit_tool_ = CreateToolButton(Tool::kEdit);
|
||||
btn_ripple_tool_ = CreateToolButton(Tool::kRipple);
|
||||
btn_rolling_tool_ = CreateToolButton(Tool::kRolling);
|
||||
btn_razor_tool_ = CreateToolButton(Tool::kRazor);
|
||||
btn_slip_tool_ = CreateToolButton(Tool::kSlip);
|
||||
btn_slide_tool_ = CreateToolButton(Tool::kSlide);
|
||||
btn_hand_tool_ = CreateToolButton(Tool::kHand);
|
||||
btn_zoom_tool_ = CreateToolButton(Tool::kZoom);
|
||||
btn_record_ = CreateToolButton(Tool::kRecord);
|
||||
btn_transition_tool_ = CreateToolButton(Tool::kTransition);
|
||||
btn_add_ = CreateToolButton(Tool::kAdd);
|
||||
|
||||
// Create snapping button, which is not actually a tool, it's a toggle option
|
||||
btn_snapping_toggle_ = CreateNonToolButton();
|
||||
@@ -55,7 +55,7 @@ Toolbar::Toolbar(QWidget *parent) :
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
void Toolbar::SetTool(const olive::tool::Tool& tool)
|
||||
void Toolbar::SetTool(const Tool::Item& tool)
|
||||
{
|
||||
// For each tool, set the "checked" state to whether the button's tool is the current tool
|
||||
for (int i=0;i<toolbar_btns_.size();i++) {
|
||||
@@ -115,7 +115,7 @@ void Toolbar::UpdateIcons()
|
||||
btn_snapping_toggle_->setIcon(olive::icon::Snapping);
|
||||
}
|
||||
|
||||
ToolbarButton* Toolbar::CreateToolButton(const olive::tool::Tool& tool)
|
||||
ToolbarButton* Toolbar::CreateToolButton(const Tool::Item& tool)
|
||||
{
|
||||
// Create a ToolbarButton object
|
||||
ToolbarButton* b = new ToolbarButton(this, tool);
|
||||
@@ -135,7 +135,7 @@ ToolbarButton* Toolbar::CreateToolButton(const olive::tool::Tool& tool)
|
||||
ToolbarButton *Toolbar::CreateNonToolButton()
|
||||
{
|
||||
// Create a ToolbarButton object
|
||||
ToolbarButton* b = new ToolbarButton(this, olive::tool::kNone);
|
||||
ToolbarButton* b = new ToolbarButton(this, Tool::kNone);
|
||||
|
||||
// Add it to the layout
|
||||
layout_->addWidget(b);
|
||||
@@ -146,7 +146,7 @@ ToolbarButton *Toolbar::CreateNonToolButton()
|
||||
void Toolbar::ToolButtonClicked()
|
||||
{
|
||||
// Get new tool from ToolbarButton object
|
||||
olive::tool::Tool new_tool = static_cast<ToolbarButton*>(sender())->tool();
|
||||
Tool::Item new_tool = static_cast<ToolbarButton*>(sender())->tool();
|
||||
|
||||
// Set checked state of all tool buttons
|
||||
// NOTE: Not necessary if this is appropriately connected to Core
|
||||
|
||||
@@ -65,7 +65,7 @@ public slots:
|
||||
*
|
||||
* Tool to show as selected
|
||||
*/
|
||||
void SetTool(const olive::tool::Tool &tool);
|
||||
void SetTool(const Tool::Item &tool);
|
||||
|
||||
/**
|
||||
* @brief Set snapping checked value
|
||||
@@ -95,7 +95,7 @@ signals:
|
||||
*
|
||||
* Tool that was selected
|
||||
*/
|
||||
void ToolChanged(const olive::tool::Tool& t);
|
||||
void ToolChanged(const Tool::Item& t);
|
||||
|
||||
/**
|
||||
* @brief Emitted whenever the snapping setting is changed
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
*
|
||||
* The created ToolbarButton. The button parent is automatically set to `this`.
|
||||
*/
|
||||
ToolbarButton* CreateToolButton(const olive::tool::Tool& tool);
|
||||
ToolbarButton* CreateToolButton(const Tool::Item& tool);
|
||||
|
||||
/**
|
||||
* @brief Internal convenience function for creating buttons quickly
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
|
||||
#include "toolbarbutton.h"
|
||||
|
||||
ToolbarButton::ToolbarButton(QWidget *parent, const olive::tool::Tool &tool) :
|
||||
ToolbarButton::ToolbarButton(QWidget *parent, const Tool::Item &tool) :
|
||||
QPushButton(parent),
|
||||
tool_(tool)
|
||||
{
|
||||
setCheckable(true);
|
||||
}
|
||||
|
||||
const olive::tool::Tool &ToolbarButton::tool()
|
||||
const Tool::Item &ToolbarButton::tool()
|
||||
{
|
||||
return tool_;
|
||||
}
|
||||
|
||||
@@ -40,21 +40,21 @@ public:
|
||||
*
|
||||
* @param tool
|
||||
*
|
||||
* Tool object. Must be a member of enum olive::tool::Tool, including kNone if this button does not represent a tool.
|
||||
* Tool object. Must be a member of enum Tool::Item, including kNone if this button does not represent a tool.
|
||||
*/
|
||||
ToolbarButton(QWidget* parent, const olive::tool::Tool& tool);
|
||||
ToolbarButton(QWidget* parent, const Tool::Item& tool);
|
||||
|
||||
/**
|
||||
* @brief Retrieve tool ID that this button represents
|
||||
*
|
||||
* Set in the constructor and shouldn't change throughout its lifetime.
|
||||
*/
|
||||
const olive::tool::Tool& tool();
|
||||
const Tool::Item& tool();
|
||||
private:
|
||||
/**
|
||||
* @brief Internal tool value
|
||||
*/
|
||||
olive::tool::Tool tool_;
|
||||
Tool::Item tool_;
|
||||
};
|
||||
|
||||
#endif // TOOLBARBUTTON_H
|
||||
|
||||
Reference in New Issue
Block a user