diff --git a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/Rack/RackPresenter.cpp b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/Rack/RackPresenter.cpp index aa7b9d570d..7156fd1541 100644 --- a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/Rack/RackPresenter.cpp +++ b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/Rack/RackPresenter.cpp @@ -13,6 +13,8 @@ #include #include +static const constexpr int slotSpacing = 0; + RackPresenter::RackPresenter(const RackModel& model, RackView* view, QObject* parent): @@ -56,7 +58,7 @@ qreal RackPresenter::height() const for(const auto& slot : slotmodels) { - totalHeight += slot.height() + 5.; + totalHeight += slot.height() + slotSpacing; } return totalHeight; @@ -161,7 +163,7 @@ void RackPresenter::updateShape() auto& slotPres = slotmodels.at(slotId); slotPres.setWidth(width()); slotPres.setVerticalPosition(currentSlotY); - currentSlotY += slotPres.height() + 5; // Separation between slots + currentSlotY += slotPres.height() + slotSpacing; // Separation between slots } // Horizontal shape diff --git a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintHeader.hpp b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintHeader.hpp index ed9948ea51..ca099aac70 100644 --- a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintHeader.hpp +++ b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintHeader.hpp @@ -6,6 +6,12 @@ class ConstraintView; class ConstraintHeader : public QGraphicsObject { public: + enum class State { + Hidden, // No rack, we show nothing + RackHidden, // There is at least a hidden rack in the constraint + RackShown // There is a rack currently shown + }; + using QGraphicsObject::QGraphicsObject; static constexpr int headerHeight() { return 25; } static const QFont font; @@ -13,7 +19,22 @@ class ConstraintHeader : public QGraphicsObject void setWidth(double width); void setText(const QString &text); + void setState(State s) + { + if(s == m_state) + return; + + if(m_state == State::Hidden) + show(); + else if(s == State::Hidden) + hide(); + + m_state = s; + update(); + } + protected: + State m_state{}; double m_width{}; QString m_text; }; diff --git a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintPresenter.cpp b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintPresenter.cpp index ffff2dcccf..92fb77c315 100644 --- a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintPresenter.cpp +++ b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/ConstraintPresenter.cpp @@ -146,7 +146,7 @@ void ConstraintPresenter::updateHeight() { if(m_viewModel.isRackShown()) { - m_view->setHeight(rack()->height() + 60); + m_view->setHeight(rack()->height() + 50); } // TODO else if(rack but not shown) else @@ -195,7 +195,7 @@ void ConstraintPresenter::on_rackShown(const Id& rackId) clearRackPresenter(); createRackPresenter(m_viewModel.model().racks.at(rackId)); - m_header->show(); + m_header->setState(ConstraintHeader::State::RackShown); updateHeight(); } @@ -203,6 +203,7 @@ void ConstraintPresenter::on_rackHidden() { clearRackPresenter(); + m_header->setState(ConstraintHeader::State::RackHidden); updateHeight(); } @@ -211,6 +212,7 @@ void ConstraintPresenter::on_rackRemoved() m_header->hide(); clearRackPresenter(); + m_header->setState(ConstraintHeader::State::Hidden); updateHeight(); } diff --git a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintHeader.cpp b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintHeader.cpp index 3ae56425f3..a8d204bd53 100644 --- a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintHeader.cpp +++ b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintHeader.cpp @@ -3,6 +3,7 @@ #include #include #include +#include QRectF TemporalConstraintHeader::boundingRect() const { return {0, 0, m_width, ConstraintHeader::headerHeight()}; @@ -10,9 +11,22 @@ QRectF TemporalConstraintHeader::boundingRect() const void TemporalConstraintHeader::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - painter->setPen(Qt::white); + if(m_state == State::RackHidden) + { + auto rect = boundingRect(); + painter->fillRect(rect, QColor::fromRgba(qRgba(0, 127, 229, 76))); + + // Fake timenode continuation + auto color = qApp->palette("ScenarioPalette").base().color(); + QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; + painter->setPen(pen); + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + painter->drawLine(rect.topRight(), rect.bottomRight()); + painter->drawLine(rect.bottomLeft(), rect.bottomRight()); + } // Header painter->setFont(font); + painter->setPen(Qt::white); QFontMetrics fm(font); int textWidth = fm.width(m_text); @@ -46,4 +60,9 @@ void TemporalConstraintHeader::paint(QPainter *painter, const QStyleOptionGraphi double w = m_width - x; double h = ConstraintHeader::headerHeight(); painter->drawText(x,y,w,h, Qt::AlignLeft, m_text); + + if(m_width > 20) + painter->drawLine( + boundingRect().bottomLeft() + QPointF{10, -5}, + boundingRect().bottomRight() + QPointF{-10, -5}); } diff --git a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintView.cpp b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintView.cpp index a643f8a6e2..905d485b3b 100644 --- a/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintView.cpp +++ b/base/plugins/iscore-plugin-scenario/source/Document/Constraint/ViewModels/Temporal/TemporalConstraintView.cpp @@ -39,7 +39,7 @@ void TemporalConstraintView::paint( int max_w = static_cast(maxWidth()); int def_w = static_cast(defaultWidth()); - // Draw the stuff present if there is a rack + // Draw the stuff present if there is a rack *in the model* ? if(presenter().rack()) { // Background