various fixes

This commit is contained in:
itsmattkc
2019-07-16 00:00:18 -04:00
parent 44668e144c
commit d098c0de5f
10 changed files with 127 additions and 21 deletions
+14 -1
View File
@@ -42,7 +42,8 @@ Core olive::core;
Core::Core() :
main_window_(nullptr),
tool_(olive::tool::kPointer)
tool_(olive::tool::kPointer),
snapping_(true)
{
}
@@ -117,6 +118,11 @@ const olive::tool::Tool &Core::tool()
return tool_;
}
const bool &Core::snapping()
{
return snapping_;
}
void Core::StartModalTask(Task *t)
{
QDialog dialog(main_window_);
@@ -144,6 +150,13 @@ void Core::SetTool(const olive::tool::Tool &tool)
emit ToolChanged(tool_);
}
void Core::SetSnapping(const bool &b)
{
snapping_ = b;
emit SnappingChanged(snapping_);
}
void Core::DialogImportShow()
{
// Open dialog for user to select files
+20 -2
View File
@@ -87,6 +87,11 @@ public:
*/
const olive::tool::Tool& tool();
/**
* @brief Get current snapping value
*/
const bool& snapping();
/**
* @brief Starts a modal task
*
@@ -104,6 +109,11 @@ public slots:
*/
void SetTool(const olive::tool::Tool& tool);
/**
* @brief Set the current snapping setting
*/
void SetSnapping(const bool& b);
/**
* @brief Open the import footage dialog and import the files selected (runs ImportFiles())
*/
@@ -126,11 +136,14 @@ signals:
/**
* @brief Signal emitted when the tool is changed from somewhere
*
* @param tool
*/
void ToolChanged(const olive::tool::Tool& tool);
/**
* @brief Signal emitted when the snapping setting is changed
*/
void SnappingChanged(const bool& b);
private:
/**
* @brief Creates an empty project and adds it to the "open projects"
@@ -188,6 +201,11 @@ private:
*/
olive::tool::Tool tool_;
/**
* @brief Current snapping toggle
*/
bool snapping_;
};
namespace olive {
+5
View File
@@ -38,6 +38,11 @@ NodeParam::Type NodeInput::type()
void NodeInput::add_data_input(const NodeParam::DataType &data_type)
{
inputs_.append(data_type);
// If no name has been set, use a default name
if (name().isEmpty()) {
set_name(GetDefaultDataTypeName(data_type));
}
}
bool NodeInput::can_accept_type(const NodeParam::DataType &data_type)
+5
View File
@@ -41,6 +41,11 @@ const NodeParam::DataType &NodeOutput::data_type()
void NodeOutput::set_data_type(const NodeParam::DataType &type)
{
data_type_ = type;
// If no name has been set, use a default name
if (name().isEmpty()) {
set_name(GetDefaultDataTypeName(type));
}
}
const QVariant &NodeOutput::get_value(const rational& time)
-1
View File
@@ -27,7 +27,6 @@
NodeParam::NodeParam(Node *parent) :
QObject(parent)
{
name_ = "Banjo";
}
const QString &NodeParam::name()
+4
View File
@@ -29,12 +29,16 @@ ToolPanel::ToolPanel(QWidget *parent) :
Toolbar* t = new Toolbar(this);
t->SetTool(olive::core.tool());
t->SetSnapping(olive::core.snapping());
setWidget(t);
connect(t, SIGNAL(ToolChanged(const olive::tool::Tool&)), &olive::core, SLOT(SetTool(const olive::tool::Tool&)));
connect(&olive::core, SIGNAL(ToolChanged(const olive::tool::Tool&)), t, SLOT(SetTool(const olive::tool::Tool&)));
connect(t, SIGNAL(SnappingChanged(const bool&)), &olive::core, SLOT(SetSnapping(const bool&)));
connect(&olive::core, SIGNAL(SnappingChanged(const bool&)), t, SLOT(SetSnapping(const bool&)));
Retranslate();
}
+42 -5
View File
@@ -36,7 +36,8 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
QGraphicsRectItem(parent),
node_(nullptr),
font_metrics(font),
expanded_(false)
expanded_(false),
standard_click_(false)
{
// Set flags for this widget
setFlag(QGraphicsItem::ItemIsMovable);
@@ -51,7 +52,7 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
node_connector_size_ = font_metrics.height() / 3;
// FIXME: Magic "number"/magic "color" - allow this to be editable by the user
SetColor(QColor(32, 32, 128));
SetColor(QColor(48, 48, 192));
}
void NodeViewItem::SetColor(const QColor &color)
@@ -161,7 +162,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QBrush connector_brush(Qt::white);
// FIXME: Same as above
QBrush content_brush(QColor("#181818"));
QBrush content_brush(QColor("#353535"));
painter->setPen(border_pen);
@@ -233,7 +234,11 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
expand_hitbox_.setWidth(expand_hitbox_.height());
// Draw the icon
olive::icon::TriRight.paint(painter, expand_hitbox_.toRect(), Qt::AlignLeft | Qt::AlignVCenter);
if (IsExpanded()) {
olive::icon::TriDown.paint(painter, expand_hitbox_.toRect(), Qt::AlignLeft | Qt::AlignVCenter);
} else {
olive::icon::TriRight.paint(painter, expand_hitbox_.toRect(), Qt::AlignLeft | Qt::AlignVCenter);
}
// Draw the text in a rect (the rect is sized around text already in the constructor)
QRectF text_rect = title_bar_rect_.adjusted(kNodeViewItemIconPadding + expand_hitbox_.width() + kNodeViewItemTextPadding,
@@ -244,6 +249,36 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
}
void NodeViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
standard_click_ = false;
// Don't initiate a drag if we clicked the expand hitbox
if (expand_hitbox_.contains(event->pos())) {
return;
}
// See if the mouse click was on a parameter connector
if (IsExpanded() // This is only possible if the node is expanded
&& node_ != nullptr) { // We can only loop through a node's parameters if a valid node is attached
for (int i=0;i<node_->ParameterCount();i++) {
if (GetParameterConnectorRect(i).contains(event->pos())) {
return;
}
}
}
standard_click_ = true;
QGraphicsRectItem::mousePressEvent(event);
}
void NodeViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (standard_click_) {
QGraphicsRectItem::mouseMoveEvent(event);
}
}
void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
// Check if we clicked the Expand/Collapse icon
@@ -251,7 +286,9 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
SetExpanded(!IsExpanded());
}
QGraphicsRectItem::mouseReleaseEvent(event);
if (standard_click_) {
QGraphicsRectItem::mouseReleaseEvent(event);
}
}
void NodeViewItem::UpdateGradient()
+4
View File
@@ -47,6 +47,8 @@ public:
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private:
@@ -69,6 +71,8 @@ private:
int node_connector_size_;
bool expanded_;
bool standard_click_;
};
#endif // NODEVIEWITEM_H
+27 -12
View File
@@ -202,61 +202,61 @@ MainMenu::MainMenu(QWidget *parent) :
//
// TOOLS MENU
//
tools_menu_ = new Menu(this);
tools_menu_ = new Menu(this, this, SLOT(ToolsMenuAboutToShow()));
tools_menu_->setToolTipsVisible(true);
QActionGroup* tools_group = new QActionGroup(this);
tools_group_ = new QActionGroup(this);
tools_pointer_item_ = tools_menu_->AddItem("pointertool", this, SLOT(ToolItemTriggered()), "V");
tools_pointer_item_->setCheckable(true);
tools_pointer_item_->setData(olive::tool::kPointer);
tools_group->addAction(tools_pointer_item_);
tools_group_->addAction(tools_pointer_item_);
tools_edit_item_ = tools_menu_->AddItem("edittool", this, SLOT(ToolItemTriggered()), "X");
tools_edit_item_->setCheckable(true);
tools_edit_item_->setData(olive::tool::kEdit);
tools_group->addAction(tools_edit_item_);
tools_group_->addAction(tools_edit_item_);
tools_ripple_item_ = tools_menu_->AddItem("rippletool", this, SLOT(ToolItemTriggered()), "B");
tools_ripple_item_->setCheckable(true);
tools_ripple_item_->setData(olive::tool::kRipple);
tools_group->addAction(tools_ripple_item_);
tools_group_->addAction(tools_ripple_item_);
tools_rolling_item_ = tools_menu_->AddItem("rollingtool", this, SLOT(ToolItemTriggered()), "N");
tools_rolling_item_->setCheckable(true);
tools_rolling_item_->setData(olive::tool::kRolling);
tools_group->addAction(tools_rolling_item_);
tools_group_->addAction(tools_rolling_item_);
tools_razor_item_ = tools_menu_->AddItem("razortool", this, SLOT(ToolItemTriggered()), "C");
tools_razor_item_->setCheckable(true);
tools_razor_item_->setData(olive::tool::kRazor);
tools_group->addAction(tools_razor_item_);
tools_group_->addAction(tools_razor_item_);
tools_slip_item_ = tools_menu_->AddItem("sliptool", this, SLOT(ToolItemTriggered()), "Y");
tools_slip_item_->setCheckable(true);
tools_slip_item_->setData(olive::tool::kSlip);
tools_group->addAction(tools_slip_item_);
tools_group_->addAction(tools_slip_item_);
tools_slide_item_ = tools_menu_->AddItem("slidetool", this, SLOT(ToolItemTriggered()), "U");
tools_slide_item_->setCheckable(true);
tools_slide_item_->setData(olive::tool::kSlide);
tools_group->addAction(tools_slide_item_);
tools_group_->addAction(tools_slide_item_);
tools_hand_item_ = tools_menu_->AddItem("handtool", this, SLOT(ToolItemTriggered()), "H");
tools_hand_item_->setCheckable(true);
tools_hand_item_->setData(olive::tool::kHand);
tools_group->addAction(tools_hand_item_);
tools_group_->addAction(tools_hand_item_);
tools_transition_item_ = tools_menu_->AddItem("transitiontool", this, SLOT(ToolItemTriggered()), "T");
tools_transition_item_->setCheckable(true);
tools_transition_item_->setData(olive::tool::kTransition);
tools_group->addAction(tools_transition_item_);
tools_group_->addAction(tools_transition_item_);
tools_menu_->addSeparator();
tools_snapping_item_ = tools_menu_->AddItem("snapping", nullptr, nullptr, "S");
tools_snapping_item_->setCheckable(true);
//tools_snapping_item_->setData(reinterpret_cast<quintptr>(panel_timeline.first()->snappingButton));
connect(tools_snapping_item_, SIGNAL(triggered(bool)), &olive::core, SLOT(SetSnapping(bool)));
tools_menu_->addSeparator();
@@ -318,6 +318,21 @@ void MainMenu::ToolItemTriggered()
olive::core.SetTool(tool);
}
void MainMenu::ToolsMenuAboutToShow()
{
// Ensure checked Tool is correct
QList<QAction*> tool_actions = tools_group_->actions();
foreach (QAction* a, tool_actions) {
if (a->data() == olive::core.tool()) {
a->setChecked(true);
break;
}
}
// Ensure snapping value is correct
tools_snapping_item_->setChecked(olive::core.snapping());
}
void MainMenu::Retranslate()
{
// MenuShared is not a QWidget and therefore does not receive a LanguageEvent, we use MainMenu's to update it
+6
View File
@@ -55,6 +55,11 @@ private slots:
*/
void ToolItemTriggered();
/**
* @brief Slot triggered just before the Tools menu shows
*/
void ToolsMenuAboutToShow();
private:
/**
* @brief Set strings based on the current application language.
@@ -127,6 +132,7 @@ private:
QAction* window_reset_layout_item_;
Menu* tools_menu_;
QActionGroup* tools_group_;
QAction* tools_pointer_item_;
QAction* tools_edit_item_;
QAction* tools_ripple_item_;