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
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#ifndef __BOX_H__
|
|
|
|
#define __BOX_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
|
|
|
Definition of HBox and VBox classes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "measurebase.h"
|
2017-01-18 22:41:58 +01:00
|
|
|
#include "property.h"
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
namespace Ms {
|
2012-05-26 14:26:10 +02:00
|
|
|
class MuseScoreView;
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Box
|
2012-08-06 08:45:08 +02:00
|
|
|
/// virtual base class for frames "boxes"
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Box : public MeasureBase
|
|
|
|
{
|
2016-09-27 13:38:28 +02:00
|
|
|
Spatium _boxWidth { Spatium(0) }; // only valid for HBox
|
|
|
|
Spatium _boxHeight { Spatium(0) }; // only valid for VBox
|
|
|
|
qreal _topGap { 0.0 }; // distance from previous system (left border for hbox)
|
2018-03-27 15:36:00 +02:00
|
|
|
// initialized with Sid::systemFrameDistance
|
2016-09-27 13:38:28 +02:00
|
|
|
qreal _bottomGap { 0.0 }; // distance to next system (right border for hbox)
|
2018-03-27 15:36:00 +02:00
|
|
|
// initialized with Sid::frameSystemDistance
|
2016-09-27 13:38:28 +02:00
|
|
|
qreal _leftMargin { 0.0 };
|
|
|
|
qreal _rightMargin { 0.0 }; // inner margins in metric mm
|
|
|
|
qreal _topMargin { 0.0 };
|
|
|
|
qreal _bottomMargin { 0.0 };
|
2021-02-02 11:02:51 +01:00
|
|
|
bool _isAutoSizeEnabled { true };
|
2016-09-27 13:38:28 +02:00
|
|
|
bool editMode { false };
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
Box(Score*);
|
2020-07-20 16:22:11 +02:00
|
|
|
|
|
|
|
void scanElements(void* data, void (* func)(void*, Element*), bool all=true) override;
|
|
|
|
|
2013-09-19 15:08:54 +02:00
|
|
|
virtual void draw(QPainter*) const override;
|
|
|
|
virtual bool isEditable() const override { return true; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2017-03-31 13:03:15 +02:00
|
|
|
virtual void startEdit(EditData&) override;
|
|
|
|
virtual bool edit(EditData&) override;
|
2017-08-16 11:21:59 +02:00
|
|
|
virtual void startEditDrag(EditData&) override;
|
2017-03-31 13:03:15 +02:00
|
|
|
virtual void editDrag(EditData&) override;
|
|
|
|
virtual void endEdit(EditData&) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2013-09-19 15:08:54 +02:00
|
|
|
virtual void layout() override;
|
2016-11-19 11:51:21 +01:00
|
|
|
virtual void write(XmlWriter&) const override;
|
2017-03-09 23:55:10 +01:00
|
|
|
virtual void write(XmlWriter& xml, int, bool, bool) const override { write(xml); }
|
2016-11-19 11:51:21 +01:00
|
|
|
virtual void writeProperties(XmlWriter&) const override;
|
2014-10-16 11:56:06 +02:00
|
|
|
virtual bool readProperties(XmlReader&) override;
|
2013-09-19 15:08:54 +02:00
|
|
|
virtual void read(XmlReader&) override;
|
2017-03-31 13:03:15 +02:00
|
|
|
virtual bool acceptDrop(EditData&) const override;
|
|
|
|
virtual Element* drop(EditData&) override;
|
2013-09-19 15:08:54 +02:00
|
|
|
virtual void add(Element* e) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2021-02-02 11:02:51 +01:00
|
|
|
QRectF contentRect() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
Spatium boxWidth() const { return _boxWidth; }
|
|
|
|
void setBoxWidth(Spatium val) { _boxWidth = val; }
|
|
|
|
Spatium boxHeight() const { return _boxHeight; }
|
|
|
|
void setBoxHeight(Spatium val) { _boxHeight = val; }
|
|
|
|
qreal leftMargin() const { return _leftMargin; }
|
|
|
|
qreal rightMargin() const { return _rightMargin; }
|
|
|
|
qreal topMargin() const { return _topMargin; }
|
|
|
|
qreal bottomMargin() const { return _bottomMargin; }
|
|
|
|
void setLeftMargin(qreal val) { _leftMargin = val; }
|
|
|
|
void setRightMargin(qreal val) { _rightMargin = val; }
|
|
|
|
void setTopMargin(qreal val) { _topMargin = val; }
|
|
|
|
void setBottomMargin(qreal val) { _bottomMargin = val; }
|
|
|
|
qreal topGap() const { return _topGap; }
|
|
|
|
void setTopGap(qreal val) { _topGap = val; }
|
|
|
|
qreal bottomGap() const { return _bottomGap; }
|
|
|
|
void setBottomGap(qreal val) { _bottomGap = val; }
|
2021-02-02 11:02:51 +01:00
|
|
|
bool isAutoSizeEnabled() const { return _isAutoSizeEnabled; }
|
|
|
|
void setAutoSizeEnabled(const bool val) { _isAutoSizeEnabled = val; }
|
2014-08-27 13:10:20 +02:00
|
|
|
void copyValues(Box* origin);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
virtual QVariant getProperty(Pid propertyId) const override;
|
|
|
|
virtual bool setProperty(Pid propertyId, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(Pid) const override;
|
2019-07-23 04:57:07 +02:00
|
|
|
virtual QString accessibleExtraInfo() const override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2019-12-12 12:28:36 +01:00
|
|
|
// TODO: add a grip for moving the entire box
|
|
|
|
EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; }
|
2019-12-13 14:04:22 +01:00
|
|
|
int gripsCount() const override { return 1; }
|
|
|
|
Grip initialEditModeGrip() const override { return Grip::START; }
|
2019-12-12 12:28:36 +01:00
|
|
|
Grip defaultGrip() const override { return Grip::START; }
|
2019-12-13 14:04:22 +01:00
|
|
|
std::vector<QPointF> gripsPositions(const EditData&) const override { return { QPointF() }; } // overriden in descendants
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ HBox
|
2014-05-16 13:44:32 +02:00
|
|
|
/// horizontal frame
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2018-03-22 09:51:50 +01:00
|
|
|
class HBox final : public Box
|
|
|
|
{
|
2016-12-12 10:31:37 +01:00
|
|
|
bool _createSystemHeader { true };
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
HBox(Score* score);
|
2016-03-30 22:33:04 +02:00
|
|
|
virtual ~HBox() {}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
HBox* clone() const override { return new HBox(*this); }
|
|
|
|
ElementType type() const override { return ElementType::HBOX; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
void layout() override;
|
|
|
|
void writeProperties(XmlWriter&) const override;
|
|
|
|
bool readProperties(XmlReader&) override;
|
|
|
|
|
|
|
|
QRectF drag(EditData&) override;
|
|
|
|
void endEditDrag(EditData&) override;
|
2012-05-26 14:26:10 +02:00
|
|
|
void layout2();
|
2020-03-25 15:06:32 +01:00
|
|
|
bool isMovable() const override;
|
|
|
|
void computeMinWidth() override;
|
2016-12-12 10:31:37 +01:00
|
|
|
|
|
|
|
bool createSystemHeader() const { return _createSystemHeader; }
|
|
|
|
void setCreateSystemHeader(bool val) { _createSystemHeader = val; }
|
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
QVariant getProperty(Pid propertyId) const override;
|
|
|
|
bool setProperty(Pid propertyId, const QVariant&) override;
|
|
|
|
QVariant propertyDefault(Pid) const override;
|
2019-12-13 14:04:22 +01:00
|
|
|
|
|
|
|
std::vector<QPointF> gripsPositions(const EditData&) const override;
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ VBox
|
2014-05-16 13:44:32 +02:00
|
|
|
/// vertical frame
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class VBox : public Box
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VBox(Score* score);
|
2016-03-30 22:33:04 +02:00
|
|
|
virtual ~VBox() {}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
VBox* clone() const override { return new VBox(*this); }
|
|
|
|
ElementType type() const override { return ElementType::VBOX; }
|
|
|
|
|
2021-02-02 11:02:51 +01:00
|
|
|
qreal minHeight() const;
|
|
|
|
qreal maxHeight() const;
|
|
|
|
|
|
|
|
QVariant getProperty(Pid propertyId) const override;
|
2020-03-25 15:06:32 +01:00
|
|
|
void layout() override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2019-12-13 14:04:22 +01:00
|
|
|
std::vector<QPointF> gripsPositions(const EditData&) const override;
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ FBox
|
|
|
|
/// frame containing fret diagrams
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class FBox : public VBox
|
|
|
|
{
|
|
|
|
public:
|
2020-05-29 18:47:27 +02:00
|
|
|
FBox(Score* score)
|
|
|
|
: VBox(score) {}
|
2016-03-30 22:33:04 +02:00
|
|
|
virtual ~FBox() {}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
FBox* clone() const override { return new FBox(*this); }
|
|
|
|
ElementType type() const override { return ElementType::FBOX; }
|
2013-05-13 18:49:17 +02:00
|
|
|
|
2020-03-25 15:06:32 +01:00
|
|
|
void layout() override;
|
|
|
|
void add(Element*) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
};
|
2013-05-13 18:49:17 +02:00
|
|
|
} // namespace Ms
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|