MuseScore/libmscore/box.cpp

749 lines
23 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "box.h"
#include "textframe.h"
2012-05-26 14:26:10 +02:00
#include "text.h"
#include "score.h"
#include "barline.h"
#include "repeat.h"
#include "symbol.h"
#include "system.h"
#include "image.h"
#include "layoutbreak.h"
#include "fret.h"
#include "mscore.h"
#include "stafftext.h"
#include "icon.h"
2014-04-09 16:09:21 +02:00
#include "xml.h"
2016-10-18 15:41:00 +02:00
#include "measure.h"
#include "undo.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2018-08-01 11:46:07 +02:00
static const ElementStyle boxStyle {
{ Sid::systemFrameDistance, Pid::TOP_GAP },
{ Sid::frameSystemDistance, Pid::BOTTOM_GAP },
};
static const ElementStyle hBoxStyle {
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// Box
//---------------------------------------------------------
Box::Box(Score* score)
: MeasureBase(score)
{
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void Box::layout()
{
MeasureBase::layout();
2016-01-04 14:48:58 +01:00
for (Element* e : el()) {
if (!e->isLayoutBreak())
2016-01-04 14:48:58 +01:00
e->layout();
2012-05-26 14:26:10 +02:00
}
}
//---------------------------------------------------------
// computeMinWidth
//---------------------------------------------------------
void HBox::computeMinWidth()
{
setWidth(point(boxWidth()) + topGap() + bottomGap()); // top/bottom is really left/right
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// draw
//---------------------------------------------------------
void Box::draw(QPainter* painter) const
{
if (score() && score()->printing())
return;
if (selected() || editMode || dropTarget() || score()->showFrames()) {
qreal w = spatium() * .15;
2013-07-04 21:07:53 +02:00
QPainterPathStroker stroker;
stroker.setWidth(w);
stroker.setJoinStyle(Qt::MiterJoin);
stroker.setCapStyle(Qt::SquareCap);
QVector<qreal> dashes ;
dashes.append(1);
dashes.append(3);
stroker.setDashPattern(dashes);
QPainterPath path;
2012-05-26 14:26:10 +02:00
w *= .5;
2013-07-04 21:07:53 +02:00
path.addRect(bbox().adjusted(w, w, -w, -w));
QPainterPath stroke = stroker.createStroke(path);
painter->setBrush(Qt::NoBrush);
painter->fillPath(stroke, (selected() || editMode || dropTarget()) ? MScore::selectColor[0] : MScore::frameMarginColor);
2012-05-26 14:26:10 +02:00
}
}
//---------------------------------------------------------
// startEdit
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
void Box::startEdit(EditData& ed)
2012-05-26 14:26:10 +02:00
{
2017-08-16 11:21:59 +02:00
Element::startEdit(ed);
2017-03-31 13:03:15 +02:00
ed.grips = 1;
ed.curGrip = Grip::START;
editMode = true;
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// edit
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
bool Box::edit(EditData&)
2012-05-26 14:26:10 +02:00
{
return false;
}
2017-08-16 11:21:59 +02:00
//---------------------------------------------------------
// startEditDrag
//---------------------------------------------------------
void Box::startEditDrag(EditData& ed)
{
ElementEditData* eed = ed.getData(this);
if (isHBox())
2018-03-27 15:36:00 +02:00
eed->pushProperty(Pid::BOX_WIDTH);
2017-08-16 11:21:59 +02:00
else
2018-03-27 15:36:00 +02:00
eed->pushProperty(Pid::BOX_HEIGHT);
2017-08-16 11:21:59 +02:00
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// editDrag
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
void Box::editDrag(EditData& ed)
2012-05-26 14:26:10 +02:00
{
if (isVBox()) {
2012-05-26 14:26:10 +02:00
_boxHeight = Spatium((ed.pos.y() - abbox().y()) / spatium());
if (ed.vRaster) {
qreal vRaster = 1.0 / MScore::vRaster();
int n = lrint(_boxHeight.val() / vRaster);
_boxHeight = Spatium(vRaster * n);
}
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
2012-05-26 14:26:10 +02:00
system()->setHeight(height());
score()->setLayout(tick());
2012-05-26 14:26:10 +02:00
}
else {
_boxWidth += Spatium(ed.delta.x() / spatium());
if (ed.hRaster) {
qreal hRaster = 1.0 / MScore::hRaster();
int n = lrint(_boxWidth.val() / hRaster);
_boxWidth = Spatium(hRaster * n);
}
score()->setLayout(tick());
2012-05-26 14:26:10 +02:00
}
layout();
}
//---------------------------------------------------------
// endEdit
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
void Box::endEdit(EditData&)
2012-05-26 14:26:10 +02:00
{
editMode = false;
layout();
}
//---------------------------------------------------------
// updateGrips
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
void Box::updateGrips(EditData& ed) const
2012-05-26 14:26:10 +02:00
{
QRectF r(abbox());
if (isHBox())
2017-03-31 13:03:15 +02:00
ed.grip[0].translate(QPointF(r.right(), r.top() + r.height() * .5));
2017-01-18 14:16:33 +01:00
else if (type() == ElementType::VBOX)
2017-03-31 13:03:15 +02:00
ed.grip[0].translate(QPointF(r.x() + r.width() * .5, r.bottom()));
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
2016-11-19 11:51:21 +01:00
void Box::write(XmlWriter& xml) const
2012-05-26 14:26:10 +02:00
{
xml.stag(name());
2014-10-16 11:56:06 +02:00
writeProperties(xml);
xml.etag();
}
//---------------------------------------------------------
// writeProperties
//---------------------------------------------------------
2016-11-19 11:51:21 +01:00
void Box::writeProperties(XmlWriter& xml) const
2014-10-16 11:56:06 +02:00
{
2018-03-27 15:36:00 +02:00
for (Pid id : {
Pid::BOX_HEIGHT, Pid::BOX_WIDTH, Pid::TOP_GAP, Pid::BOTTOM_GAP,
Pid::LEFT_MARGIN, Pid::RIGHT_MARGIN, Pid::TOP_MARGIN, Pid::BOTTOM_MARGIN }) {
2018-03-19 17:37:11 +01:00
writeProperty(xml, id);
}
2012-05-26 14:26:10 +02:00
Element::writeProperties(xml);
2016-01-04 14:48:58 +01:00
for (const Element* e : el())
e->write(xml);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
2013-01-11 18:10:18 +01:00
void Box::read(XmlReader& e)
2012-05-26 14:26:10 +02:00
{
_leftMargin = 0.0;
_rightMargin = 0.0;
_topMargin = 0.0;
_bottomMargin = 0.0;
_boxHeight = Spatium(0); // override default set in constructor
_boxWidth = Spatium(0);
2012-05-26 14:26:10 +02:00
2013-01-11 18:10:18 +01:00
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
if (tag == "HBox") {
2012-05-26 14:26:10 +02:00
HBox* hb = new HBox(score());
hb->read(e);
add(hb);
}
else if (tag == "VBox") {
VBox* vb = new VBox(score());
vb->read(e);
add(vb);
}
else if (!Box::readProperties(e))
2013-01-11 18:10:18 +01:00
e.unknown();
2012-05-26 14:26:10 +02:00
}
}
2014-10-16 11:56:06 +02:00
//---------------------------------------------------------
// readProperties
//---------------------------------------------------------
bool Box::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());
if (tag == "height")
_boxHeight = Spatium(e.readDouble());
else if (tag == "width")
_boxWidth = Spatium(e.readDouble());
else if (tag == "topGap") {
2014-10-16 11:56:06 +02:00
_topGap = e.readDouble();
if (score()->mscVersion() >= 206)
_topGap *= score()->spatium();
2018-03-27 15:36:00 +02:00
setPropertyFlags(Pid::TOP_GAP, PropertyFlags::UNSTYLED);
}
else if (tag == "bottomGap") {
2014-10-16 11:56:06 +02:00
_bottomGap = e.readDouble();
if (score()->mscVersion() >= 206)
_bottomGap *= score()->spatium();
2018-03-27 15:36:00 +02:00
setPropertyFlags(Pid::BOTTOM_GAP, PropertyFlags::UNSTYLED);
}
2014-10-16 11:56:06 +02:00
else if (tag == "leftMargin")
_leftMargin = e.readDouble();
else if (tag == "rightMargin")
_rightMargin = e.readDouble();
else if (tag == "topMargin")
_topMargin = e.readDouble();
else if (tag == "bottomMargin")
_bottomMargin = e.readDouble();
else if (tag == "Text") {
Text* t;
if (isTBox()) {
t = toTBox(this)->text();
2014-10-16 11:56:06 +02:00
t->read(e);
}
else {
t = new Text(score());
t->read(e);
2018-03-22 09:51:50 +01:00
if (t->empty())
2014-10-16 11:56:06 +02:00
qDebug("read empty text");
else
2014-10-16 11:56:06 +02:00
add(t);
}
}
else if (tag == "Symbol") {
Symbol* s = new Symbol(score());
s->read(e);
add(s);
}
else if (tag == "Image") {
if (MScore::noImages)
e.skipCurrentElement();
else {
Image* image = new Image(score());
image->setTrack(e.track());
image->read(e);
add(image);
}
}
else if (tag == "FretDiagram") {
FretDiagram* f = new FretDiagram(score());
f->read(e);
add(f);
}
else if (tag == "HBox") {
HBox* hb = new HBox(score());
hb->read(e);
add(hb);
}
else if (tag == "VBox") {
VBox* vb = new VBox(score());
vb->read(e);
add(vb);
}
2016-01-04 14:48:58 +01:00
else if (MeasureBase::readProperties(e))
2014-10-16 11:56:06 +02:00
;
else
return false;
return true;
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// add
/// Add new Element \a el to Box
//---------------------------------------------------------
void Box::add(Element* e)
{
2017-12-20 16:49:30 +01:00
if (e->isText())
toText(e)->setLayoutToParentWidth(true);
2012-05-26 14:26:10 +02:00
MeasureBase::add(e);
}
//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
QVariant Box::getProperty(Pid propertyId) const
2012-05-26 14:26:10 +02:00
{
2012-08-10 17:01:35 +02:00
switch(propertyId) {
2018-03-27 15:36:00 +02:00
case Pid::BOX_HEIGHT:
2016-03-05 15:31:26 +01:00
return _boxHeight;
2018-03-27 15:36:00 +02:00
case Pid::BOX_WIDTH:
2016-03-05 15:31:26 +01:00
return _boxWidth;
2018-03-27 15:36:00 +02:00
case Pid::TOP_GAP:
2012-08-10 17:01:35 +02:00
return _topGap;
2018-03-27 15:36:00 +02:00
case Pid::BOTTOM_GAP:
2012-08-10 17:01:35 +02:00
return _bottomGap;
2018-03-27 15:36:00 +02:00
case Pid::LEFT_MARGIN:
2012-08-10 17:01:35 +02:00
return _leftMargin;
2018-03-27 15:36:00 +02:00
case Pid::RIGHT_MARGIN:
2012-08-10 17:01:35 +02:00
return _rightMargin;
2018-03-27 15:36:00 +02:00
case Pid::TOP_MARGIN:
2012-08-10 17:01:35 +02:00
return _topMargin;
2018-03-27 15:36:00 +02:00
case Pid::BOTTOM_MARGIN:
2012-08-10 17:01:35 +02:00
return _bottomMargin;
default:
return MeasureBase::getProperty(propertyId);
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
bool Box::setProperty(Pid propertyId, const QVariant& v)
2012-05-26 14:26:10 +02:00
{
score()->addRefresh(canvasBoundingRect());
switch (propertyId) {
2018-03-27 15:36:00 +02:00
case Pid::BOX_HEIGHT:
2016-03-05 15:31:26 +01:00
_boxHeight = v.value<Spatium>();
2012-05-26 14:26:10 +02:00
break;
2018-03-27 15:36:00 +02:00
case Pid::BOX_WIDTH:
2016-03-05 15:31:26 +01:00
_boxWidth = v.value<Spatium>();
2012-08-10 17:01:35 +02:00
break;
2018-03-27 15:36:00 +02:00
case Pid::TOP_GAP:
2012-08-10 17:01:35 +02:00
_topGap = v.toDouble();
break;
2018-03-27 15:36:00 +02:00
case Pid::BOTTOM_GAP:
2012-08-10 17:01:35 +02:00
_bottomGap = v.toDouble();
break;
2018-03-27 15:36:00 +02:00
case Pid::LEFT_MARGIN:
2012-08-10 17:01:35 +02:00
_leftMargin = v.toDouble();
break;
2018-03-27 15:36:00 +02:00
case Pid::RIGHT_MARGIN:
2012-08-10 17:01:35 +02:00
_rightMargin = v.toDouble();
break;
2018-03-27 15:36:00 +02:00
case Pid::TOP_MARGIN:
2012-08-10 17:01:35 +02:00
_topMargin = v.toDouble();
break;
2018-03-27 15:36:00 +02:00
case Pid::BOTTOM_MARGIN:
2012-08-10 17:01:35 +02:00
_bottomMargin = v.toDouble();
break;
default:
return MeasureBase::setProperty(propertyId, v);
2012-05-26 14:26:10 +02:00
}
score()->setLayout(tick());
2012-08-10 17:01:35 +02:00
return true;
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
QVariant Box::propertyDefault(Pid id) const
2012-05-26 14:26:10 +02:00
{
2012-08-10 17:01:35 +02:00
switch(id) {
2018-03-27 15:36:00 +02:00
case Pid::BOX_HEIGHT:
case Pid::BOX_WIDTH:
2016-03-05 15:31:26 +01:00
return Spatium(0.0);
2018-03-27 15:36:00 +02:00
case Pid::TOP_GAP:
return isHBox() ? 0.0 : score()->styleP(Sid::systemFrameDistance);
case Pid::BOTTOM_GAP:
return isHBox() ? 0.0 : score()->styleP(Sid::frameSystemDistance);
2012-08-10 17:01:35 +02:00
2018-03-27 15:36:00 +02:00
case Pid::LEFT_MARGIN:
case Pid::RIGHT_MARGIN:
case Pid::TOP_MARGIN:
case Pid::BOTTOM_MARGIN:
return 0.0;
2012-08-10 17:01:35 +02:00
default:
return MeasureBase::propertyDefault(id);
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// copyValues
//---------------------------------------------------------
void Box::copyValues(Box* origin)
{
_boxHeight = origin->boxHeight();
_boxWidth = origin->boxWidth();
qreal factor = magS() / origin->magS();
_bottomGap = origin->bottomGap() * factor;
_topGap = origin->topGap() * factor;
_bottomMargin = origin->bottomMargin() * factor;
_topMargin = origin->topMargin() * factor;
_leftMargin = origin->leftMargin() * factor;
_rightMargin = origin->rightMargin() * factor;
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// HBox
//---------------------------------------------------------
HBox::HBox(Score* score)
: Box(score)
{
2018-08-01 11:46:07 +02:00
initElementStyle(&hBoxStyle);
2012-05-26 14:26:10 +02:00
setBoxWidth(Spatium(5.0));
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void HBox::layout()
{
2017-12-20 16:49:30 +01:00
if (parent() && parent()->isVBox()) {
VBox* vb = toVBox(parent());
2015-11-16 14:24:47 +01:00
qreal x = vb->leftMargin() * DPMM;
qreal y = vb->topMargin() * DPMM;
2012-05-26 14:26:10 +02:00
qreal w = point(boxWidth());
2015-11-16 14:24:47 +01:00
qreal h = vb->height() - (vb->topMargin() + vb->bottomMargin()) * DPMM;
2012-05-26 14:26:10 +02:00
setPos(x, y);
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, w, h);
2012-05-26 14:26:10 +02:00
}
else {
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, point(boxWidth()), system()->height());
2012-05-26 14:26:10 +02:00
}
Box::layout();
}
//---------------------------------------------------------
// layout2
// height (bbox) is defined now
//---------------------------------------------------------
void HBox::layout2()
{
Box::layout();
}
//---------------------------------------------------------
// acceptDrop
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
bool Box::acceptDrop(EditData& data) const
2012-05-26 14:26:10 +02:00
{
2017-01-18 14:16:33 +01:00
ElementType t = data.element->type();
2014-08-13 21:01:21 +02:00
if (data.element->flag(ElementFlag::ON_STAFF))
return false;
2016-10-18 15:41:00 +02:00
switch (t) {
2017-01-18 14:16:33 +01:00
case ElementType::LAYOUT_BREAK:
case ElementType::TEXT:
case ElementType::STAFF_TEXT:
case ElementType::IMAGE:
case ElementType::SYMBOL:
2012-05-26 14:26:10 +02:00
return true;
2017-01-18 14:16:33 +01:00
case ElementType::ICON:
2016-10-18 15:41:00 +02:00
switch (toIcon(data.element)->iconType()) {
case IconType::VFRAME:
case IconType::TFRAME:
case IconType::FFRAME:
case IconType::MEASURE:
2012-05-26 14:26:10 +02:00
return true;
default:
break;
2012-05-26 14:26:10 +02:00
}
break;
2017-01-18 14:16:33 +01:00
case ElementType::BAR_LINE:
return type() == ElementType::HBOX;
default:
break;
2012-05-26 14:26:10 +02:00
}
return false;
}
//---------------------------------------------------------
// drop
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
Element* Box::drop(EditData& data)
2012-05-26 14:26:10 +02:00
{
Element* e = data.element;
if (e->flag(ElementFlag::ON_STAFF))
return 0;
switch (e->type()) {
2017-01-18 14:16:33 +01:00
case ElementType::LAYOUT_BREAK:
2012-05-26 14:26:10 +02:00
{
2017-12-20 16:49:30 +01:00
LayoutBreak* lb = toLayoutBreak(e);
2016-01-04 14:48:58 +01:00
if (pageBreak() || lineBreak()) {
2012-05-26 14:26:10 +02:00
if (
2016-10-18 15:41:00 +02:00
(lb->isPageBreak() && pageBreak())
|| (lb->isLineBreak() && lineBreak())
|| (lb->isSectionBreak() && sectionBreak())
2012-05-26 14:26:10 +02:00
) {
//
// if break already set
//
delete lb;
break;
}
2016-01-04 14:48:58 +01:00
for (Element* elem : el()) {
2017-01-18 14:16:33 +01:00
if (elem->type() == ElementType::LAYOUT_BREAK) {
2012-05-26 14:26:10 +02:00
score()->undoChangeElement(elem, e);
break;
}
}
break;
}
lb->setTrack(-1); // these are system elements
2012-05-26 14:26:10 +02:00
lb->setParent(this);
score()->undoAddElement(lb);
return lb;
}
2017-01-18 14:16:33 +01:00
case ElementType::STAFF_TEXT:
2012-05-26 14:26:10 +02:00
{
2018-08-01 11:46:07 +02:00
Text* text = new Text(score(), Tid::FRAME);
2012-05-26 14:26:10 +02:00
text->setParent(this);
2017-12-20 16:49:30 +01:00
text->setXmlText(toStaffText(e)->xmlText());
2012-05-26 14:26:10 +02:00
score()->undoAddElement(text);
delete e;
return text;
}
2017-01-18 14:16:33 +01:00
case ElementType::ICON:
2016-10-18 15:41:00 +02:00
switch (toIcon(e)->iconType()) {
case IconType::VFRAME:
2017-01-18 14:16:33 +01:00
score()->insertMeasure(ElementType::VBOX, this);
2012-05-26 14:26:10 +02:00
break;
case IconType::TFRAME:
2017-01-18 14:16:33 +01:00
score()->insertMeasure(ElementType::TBOX, this);
2012-05-26 14:26:10 +02:00
break;
case IconType::FFRAME:
2017-01-18 14:16:33 +01:00
score()->insertMeasure(ElementType::FBOX, this);
2012-05-26 14:26:10 +02:00
break;
case IconType::MEASURE:
2017-01-18 14:16:33 +01:00
score()->insertMeasure(ElementType::MEASURE, this);
2012-05-26 14:26:10 +02:00
break;
default:
break;
2012-05-26 14:26:10 +02:00
}
break;
2017-01-18 14:16:33 +01:00
case ElementType::TEXT:
case ElementType::IMAGE:
case ElementType::SYMBOL:
2012-05-26 14:26:10 +02:00
e->setParent(this);
score()->undoAddElement(e);
return e;
default:
return 0;
2012-05-26 14:26:10 +02:00
}
return 0;
}
//---------------------------------------------------------
// drag
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
QRectF HBox::drag(EditData& data)
2012-05-26 14:26:10 +02:00
{
QRectF r(canvasBoundingRect());
2017-03-31 13:03:15 +02:00
qreal diff = data.delta.x();
qreal x1 = offset().x() + diff;
2017-01-18 14:16:33 +01:00
if (parent()->type() == ElementType::VBOX) {
2017-12-20 16:49:30 +01:00
VBox* vb = toVBox(parent());
2015-11-16 14:24:47 +01:00
qreal x2 = parent()->width() - width() - (vb->leftMargin() + vb->rightMargin()) * DPMM;
2012-05-26 14:26:10 +02:00
if (x1 < 0.0)
x1 = 0.0;
else if (x1 > x2)
x1 = x2;
}
setOffset(QPointF(x1, 0.0));
2017-03-31 13:03:15 +02:00
// setStartDragPosition(data.delta);
2012-05-26 14:26:10 +02:00
return canvasBoundingRect() | r;
}
//---------------------------------------------------------
// endEditDrag
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
void HBox::endEditDrag(EditData&)
2012-05-26 14:26:10 +02:00
{
score()->setLayout(tick());
2013-06-05 15:47:34 +02:00
score()->update();
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// isMovable
//---------------------------------------------------------
bool HBox::isMovable() const
{
return parent() && (parent()->isHBox() || parent()->isVBox());
}
//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
QVariant HBox::getProperty(Pid propertyId) const
{
switch (propertyId) {
2018-03-27 15:36:00 +02:00
case Pid::CREATE_SYSTEM_HEADER:
return createSystemHeader();
default:
return Box::getProperty(propertyId);
}
}
//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
bool HBox::setProperty(Pid propertyId, const QVariant& v)
{
switch (propertyId) {
2018-03-27 15:36:00 +02:00
case Pid::CREATE_SYSTEM_HEADER:
setCreateSystemHeader(v.toBool());
score()->setLayout(tick());
break;
default:
return Box::setProperty(propertyId, v);
}
return true;
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
QVariant HBox::propertyDefault(Pid id) const
{
switch(id) {
2018-03-27 15:36:00 +02:00
case Pid::CREATE_SYSTEM_HEADER:
return true;
default:
return Box::propertyDefault(id);
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// VBox
//---------------------------------------------------------
VBox::VBox(Score* score)
: Box(score)
{
2018-08-01 11:46:07 +02:00
initElementStyle(&boxStyle);
2012-05-26 14:26:10 +02:00
setBoxHeight(Spatium(10.0));
setLineBreak(true);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void VBox::layout()
{
2018-10-26 10:41:07 +02:00
setPos(QPointF());
2012-05-26 14:26:10 +02:00
if (system())
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
2012-05-26 14:26:10 +02:00
else
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, 50, 50);
2012-05-26 14:26:10 +02:00
Box::layout();
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void FBox::layout()
{
2012-09-24 14:48:43 +02:00
// setPos(QPointF()); // !?
2013-01-02 09:29:17 +01:00
bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
2012-05-26 14:26:10 +02:00
Box::layout();
}
//---------------------------------------------------------
// add
/// Add new Element \a e to fret diagram box
//---------------------------------------------------------
void FBox::add(Element* e)
{
e->setParent(this);
2017-12-20 16:49:30 +01:00
if (e->isFretDiagram()) {
// FretDiagram* fd = toFretDiagram(e);
// fd->setFlag(ElementFlag::MOVABLE, false);
2012-05-26 14:26:10 +02:00
}
else {
qDebug("FBox::add: element not allowed");
2012-05-26 14:26:10 +02:00
return;
}
2016-01-04 14:48:58 +01:00
el().push_back(e);
2012-05-26 14:26:10 +02:00
}
2013-05-13 18:49:17 +02:00
}