MuseScore/libmscore/bsymbol.h
Kumar Kartikay a87cc9e6cc Create Score Tree Model
This commit adds virtual functions treeChild, treeParent and
treeChildCount to ScoreElement and implements them in most non-leaf-node
classes. An iterator is also added to ScoreElement class to iterate over
the children of any element.

In this model, Spanners, Beams and Ties are given a single parent, which
is the starting element of the spanner, beam or tie. Also, to ensure
consistency in the model, spanners, beams, and ties appear in the
children list only for their starting element. Children of spanner
elements are SpannerSegments, one for each system the spanner appears
in.
2020-06-23 12:44:57 +05:30

62 lines
2 KiB
C++

//=============================================================================
// 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 __BSYMBOL_H__
#define __BSYMBOL_H__
#include "element.h"
namespace Ms {
//---------------------------------------------------------
// @@ BSymbol
/// base class for Symbol and Image
//---------------------------------------------------------
class BSymbol : public Element
{
QList<Element*> _leafs;
Align _align;
public:
BSymbol(Score* s, ElementFlags f = ElementFlag::NOTHING);
BSymbol(const BSymbol&);
// Score Tree functions
ScoreElement* treeParent() const override;
ScoreElement* treeChild(int idx) const override;
int treeChildCount() const override;
BSymbol& operator=(const BSymbol&) = delete;
virtual void add(Element*) override;
virtual void remove(Element*) override;
virtual void scanElements(void* data, void (* func)(void*, Element*), bool all=true) override;
virtual bool acceptDrop(EditData&) const override;
virtual Element* drop(EditData&) override;
virtual void layout() override;
virtual QRectF drag(EditData&) override;
void writeProperties(XmlWriter& xml) const;
bool readProperties(XmlReader&);
Align align() const { return _align; }
void setAlign(Align a) { _align = a; }
const QList<Element*>& leafs() const { return _leafs; }
QList<Element*>& leafs() { return _leafs; }
virtual QPointF pagePos() const override;
virtual QPointF canvasPos() const override;
QVector<QLineF> dragAnchorLines() const override;
Segment* segment() const { return (Segment*)parent(); }
};
} // namespace Ms
#endif