diff --git a/application/sources/bone_manage_widget.cc b/application/sources/bone_manage_widget.cc index 5d5923a6..db88f327 100644 --- a/application/sources/bone_manage_widget.cc +++ b/application/sources/bone_manage_widget.cc @@ -4,7 +4,6 @@ #include "bone_property_widget.h" #include "document.h" #include "theme.h" -#include #include #include @@ -76,15 +75,23 @@ void BoneManageWidget::showSelectedBoneProperties() auto* propertyWidget = new BonePropertyWidget(m_document, boneIds); - auto menu = std::make_unique(this->parentWidget()); - QWidgetAction* widgetAction = new QWidgetAction(menu.get()); + m_propertyMenu = std::make_unique(this->parentWidget()); + + connect(propertyWidget, &BonePropertyWidget::pickBoneJoints, this, [this]() { + if (nullptr == this->m_propertyMenu) + return; + this->m_document->setEditMode(Document::EditMode::Pick); + this->m_propertyMenu->close(); + }); + + QWidgetAction* widgetAction = new QWidgetAction(m_propertyMenu.get()); widgetAction->setDefaultWidget(propertyWidget); - menu->addAction(widgetAction); + m_propertyMenu->addAction(widgetAction); auto x = mapToGlobal(QPoint(0, 0)).x(); if (x <= 0) x = QCursor::pos().x(); - menu->exec(QPoint( + m_propertyMenu->exec(QPoint( x - propertyWidget->width(), QCursor::pos().y())); } diff --git a/application/sources/bone_manage_widget.h b/application/sources/bone_manage_widget.h index d9314625..3bca6e22 100644 --- a/application/sources/bone_manage_widget.h +++ b/application/sources/bone_manage_widget.h @@ -1,8 +1,10 @@ #ifndef DUST3D_APPLICATION_BONE_MANAGE_WIDGET_H_ #define DUST3D_APPLICATION_BONE_MANAGE_WIDGET_H_ +#include #include #include +#include class Document; class BonePreviewGridWidget; @@ -29,6 +31,7 @@ private: QPushButton* m_addButton = nullptr; QPushButton* m_selectButton = nullptr; QPushButton* m_propertyButton = nullptr; + std::unique_ptr m_propertyMenu; void updateToolButtons(); }; diff --git a/application/sources/bone_property_widget.cc b/application/sources/bone_property_widget.cc index be19a7df..e898a0d4 100644 --- a/application/sources/bone_property_widget.cc +++ b/application/sources/bone_property_widget.cc @@ -2,6 +2,7 @@ #include "float_number_widget.h" #include "image_preview_widget.h" #include "theme.h" +#include #include #include #include @@ -33,7 +34,23 @@ BonePropertyWidget::BonePropertyWidget(Document* document, renameLayout->addWidget(m_nameEdit); renameLayout->addStretch(); + m_jointsWidget = new IntNumberWidget; + m_jointsWidget->setRange(2, 10); + + QPushButton* nodePicker = new QPushButton(QChar(fa::eyedropper)); + nodePicker->setToolTip(tr("Click node one by one on canvas as joints in order")); + Theme::initIconButton(nodePicker); + + connect(nodePicker, &QPushButton::clicked, this, &BonePropertyWidget::pickBoneJoints); + + QHBoxLayout* jointsLayout = new QHBoxLayout; + jointsLayout->addWidget(new QLabel(tr("Joints"))); + jointsLayout->addWidget(m_jointsWidget); + jointsLayout->addStretch(); + jointsLayout->addWidget(nodePicker); + mainLayout->addLayout(renameLayout); + mainLayout->addLayout(jointsLayout); } mainLayout->setSizeConstraint(QLayout::SetFixedSize); diff --git a/application/sources/bone_property_widget.h b/application/sources/bone_property_widget.h index 6b0c17bb..a8104eaa 100644 --- a/application/sources/bone_property_widget.h +++ b/application/sources/bone_property_widget.h @@ -2,6 +2,7 @@ #define DUST3D_APPLICATION_BONE_PROPERTY_WIDGET_H_ #include "document.h" +#include "int_number_widget.h" #include #include @@ -12,6 +13,7 @@ class BonePropertyWidget : public QWidget { signals: void renameBone(const dust3d::Uuid& boneId, const QString& name); void groupOperationAdded(); + void pickBoneJoints(); public: BonePropertyWidget(Document* document, @@ -26,6 +28,7 @@ private: dust3d::Uuid m_boneId; const Document::Bone* m_bone = nullptr; QLineEdit* m_nameEdit = nullptr; + IntNumberWidget* m_jointsWidget = nullptr; void prepareBoneIds(); }; diff --git a/application/sources/int_number_widget.cc b/application/sources/int_number_widget.cc index 88df3967..cd97c13b 100644 --- a/application/sources/int_number_widget.cc +++ b/application/sources/int_number_widget.cc @@ -9,7 +9,7 @@ IntNumberWidget::IntNumberWidget(QWidget* parent, bool singleLine) { m_slider = new QSlider(Qt::Horizontal, this); m_slider->setRange(0, 100); - m_slider->setFixedWidth(240); + m_slider->setFixedWidth(Theme::sidebarPreferredWidth * 0.6); m_label = new QLabel(this); m_label->setAlignment(Qt::AlignLeft); diff --git a/application/sources/skeleton_graphics_widget.cc b/application/sources/skeleton_graphics_widget.cc index 48735a94..77fd41bd 100644 --- a/application/sources/skeleton_graphics_widget.cc +++ b/application/sources/skeleton_graphics_widget.cc @@ -705,8 +705,7 @@ void SkeletonGraphicsWidget::updateCursor() setCursor(Qt::CrossCursor); break; default: - unsetCursor(); - break; + setCursor(Qt::ArrowCursor); } emit cursorChanged(); @@ -827,7 +826,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent* event) } } - if (Document::EditMode::Select == m_document->editMode || Document::EditMode::Add == m_document->editMode) { + if (Document::EditMode::Select == m_document->editMode || Document::EditMode::Add == m_document->editMode || Document::EditMode::Pick == m_document->editMode) { // // > For overlapping nodes, you can make it a bit better by selecting the node center nearest the mouse, rather than simply checking against the wider circle.